package fr.afcepf.atodcp2.benbai.dao.implementations;

import java.util.ArrayList;
import java.util.List;

import fr.afcepf.atodcp2.benbai.dao.generique.GenericDaoHibernateTemplateImpl;
import fr.afcepf.atodcp2.benbai.dao.interfaces.IDaoPanier;
import fr.afcepf.atodcp2.benbai.entity.Client;
import fr.afcepf.atodcp2.benbai.entity.Commande;
import fr.afcepf.atodcp2.benbai.entity.Panier;

public class DaoPanier extends GenericDaoHibernateTemplateImpl<Panier, Integer> implements
		IDaoPanier {
	
	@SuppressWarnings("unchecked")
	@Override
	public Panier getPanierByCommande(Commande commande) {
		Panier panier = new Panier();
		List<Panier> lp = new ArrayList<Panier>();
		String param = "paramIdPanier";
		Object value = commande.getPanier().getIdPanier();
		lp = hibernateTemplate.findByNamedParam("FROM Panier p WHERE p.idPanier like :paramIdPanier", param, value);
		panier = lp.get(0);
		return panier;
	}	
	
}
